package com.complex.spring.advance.service.messagesource;

import java.util.Date;
import java.util.Locale;

import org.springframework.context.ApplicationContext;
import org.springframework.context.MessageSource;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * MessageSource两种注入方式
 * 1.实现MessageSourceAware(也需要MessageSource的bean定义)
 * 2.bean注入
 * @author gao
 *
 */
public class TestMessageSourceInjection{
	private MessageSource messageSource;
	
	public static void main(String[] args) {
		ApplicationContext context = new ClassPathXmlApplicationContext("bean/spring-service.xml");
		TestMessageSourceInjection test = (TestMessageSourceInjection)context.getBean("testMessageSourceInjection");
		test.messageSource.getMessage("menu.file", new Object[]{"arg0",new Date()}, Locale.US);
		
	}

	public MessageSource getMessageSource() {
		return messageSource;
	}

	public void setMessageSource(MessageSource messageSource) {
		this.messageSource = messageSource;
	}
}
